package codeTools;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Blob;
import java.sql.SQLException;

public class MyDecoder {//解码
	public static void blobToPicture(Blob blob, String picture) throws SQLException, IOException {
		InputStream inputStream = blob.getBinaryStream();
		
		byte[] readBuffer = new byte[1024];
		
		FileOutputStream fos = new FileOutputStream(picture);
		int readLength = 0;
		while (true) {
			readLength = inputStream.read(readBuffer);
			if(readLength == -1) {
				break;
			}
			fos.write(readBuffer, 0, readLength);// 将数据库的图片写出
		}
		fos.close();
	}
}
